﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace LotteryAdmin
{
    public partial class App : Application
    {
        private static Dictionary<string, Object> m_Session = new Dictionary<string, object>();
        public App()
        {
            this.Startup += this.Application_Startup;
            this.UnhandledException += this.Application_UnhandledException;

            InitializeComponent();
        }
        public static Dictionary<string, Object> Session
        {
            get
            {
                return App.m_Session;
            }
            set
            {
                App.m_Session = value;
            }
        }
        private Grid rootGrid = new Grid();
        public static void Navigation(UserControl newPage)
        {
            //获取当前的Appliaction实例 
            App currentApp = (App)Application.Current;
            //修改当前显示页面内容. 
            currentApp.rootGrid.Children.Clear();
            currentApp.rootGrid.Children.Add(newPage);
        }
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            this.RootVisual = rootGrid;
            rootGrid.Children.Add(new LoginPage());
        }

        private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
        {
            if (!System.Diagnostics.Debugger.IsAttached)
            {
                e.Handled = true;
                return;
                ChildWindow errorWin = new ErrorWindow(e.ExceptionObject);
                errorWin.Show();
            }
        }
    }
}